#include <iostream>
#include <algorithm>

using namespace std;

const int N = 100010, M = 3000000;
int son[M][2];
int a[N], idx;

void insert(int x)
{
    int p = 0;
    for (int i = 30; i >= 0; --i)
    {
        int &s = son[p][x >> i & 1];
        if (!s)
        {
            s = ++idx;
        }
        p = s;
    }
}

int query(int x)
{
    //由于 这个数本身在Trie树中，所以可以保证不会出现没有路的情况
    //因此不会返回最开始的位置
    int res = 0, p = 0;
    for (int i = 30; i >= 0; --i)
    {
        int u = x >> i & 1;
        if (son[p][!u])
        {
            res += 1 << i;
            p = son[p][!u];
        }
        else
        {
            p = son[p][u];
        }
    }
    return res;
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &a[i]);
        insert(a[i]);
    }

    int res = 0;
    for (int i = 0; i < n; ++i)
    {
        res = max(res, query(a[i]));
    }
    return 0;
}